package com.jianganming.singleton;

import java.lang.reflect.Constructor;

/**
 * 破坏单例方式二：反射
 */
public class Reflex {
    public static void main(String[] args)throws Exception {
        Singleton singleton = Singleton.getInstance();

        Class<Singleton> singletonClass = Singleton.class;
        Constructor<Singleton> constructor = singletonClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        Singleton singleton1 = constructor.newInstance();
        System.out.println(singleton);
        System.out.println(singleton1);
    }
}
